package graph.algorithm;

import javax.vecmath.Matrix3d;

import graph.Graph;
import graph.Node;

public class Rotator implements Transformer {
	private int dx;
	private int dy;
	public Rotator(int dx, int dy) {
		this.dx = dx;
		this.dy = dy;
	}
	@Override
	public <T,V> void transform(Graph<T,V> graph) {
		Matrix3d rx = new Matrix3d();
		rx.rotX(dy/-160.0);
		Matrix3d ry = new Matrix3d();
		ry.rotY(dx/160.0);
		ry.mul(rx);
		transform(graph, ry);
	}
	public static void transform(Graph<?,?> graph, Matrix3d m)
	{
		for (Node<?> node : graph.getNodes())
		{
			node.transform(m);
		}
	}

}
